#include "Item.h"
#include "BaseCharacter.h"
#include "GamePlayState.h"

Item::Item(int ID)
{
	ItemID = ID;
	name = nullptr;
}

Item::~Item(void)
{
}

bool Item::ApplyEffect(int ID, BaseCharacter* target)
{
	switch(ID)
	{
	case HPOTION:
		{
			if(target->GetHP() < target->GetMaxHP())
			{
				GamePlayState::GetInstance()->SetHealing(target->GetMaxHP() - target->GetHP());
				target->SetHP(target->GetHP()+10);
				if(target->GetHP() > target->GetMaxHP())
					target->SetHP(target->GetMaxHP());
				return true;
			}
			else
			{
				return false;
			}
			break;
		}

	case MPOTION:
		{
			if(target->GetType() == 4)
			{
				if(target->GetMP() < target->GetMaxMP())
				{
					target->SetMP(target->GetMP()+30);
					if(target->GetMP() > target->GetMaxMP())
						target->SetMP(target->GetMaxMP());
					return true;
				}
				else
				{
					return false;
				}
			}
			else
			{
				return false;
			}
			break;
		}

	case INHALER:
		{
			return false;
			break;
		}

	case KN_WPN:
		{
			target->SetWpnName(name);
			target->SetWpn(value);
			return true;
			break;
		}

	case KN_ARM:
		{
			target->SetArmName(name);
			target->SetArm(value);
			return true;
			break;
		}

	case WIZ_WPN:
		{
			target->SetWpnName(name);
			target->SetWpn(value);
			return true;
			break;
		}

	case WIZ_ARM:
		{
			target->SetArmName(name);
			target->SetArm(value);
			return true;
			break;
		}

	case ARCH_WPN:
		{
			target->SetWpnName(name);
			target->SetWpn(value);
			return true;
			break;
		}

	case ARCH_ARM:
		{
			target->SetArmName(name);
			target->SetArm(value);
			return true;
			break;
		}

	case RG_WPN:
		{
			target->SetWpnName(name);
			target->SetWpn(value);
			return true;
			break;
		}

	case RG_ARM:
		{
			target->SetArmName(name);
			target->SetArm(value);
			return true;
			break;
		}
	};
	return false;
}